void a(vector<TH1 *> &v, TH1 *h){ v.push_back(h); }
void prim(TH1 *h, const string &xtitle){
	h->GetXaxis()->SetTitle(xtitle.data());
}
void prim2(TH1 *h, const string &xtitle, const string &ytitle){
	h->GetXaxis()->SetTitle(xtitle.data());
	h->GetYaxis()->SetTitle(ytitle.data());
}

void show(){
	char rf[128]{}; strcpy(rf, getenv("TMP1")); // rootfile name
	TFile *f = new TFile(rf, "update");
	TTree *eg4 = (TTree *)f->Get("eg4");
	vector<TH1 *> v;

	TH1F *hphi = new TH1F("hphi", "phi", 500, -70., 70.);
	TH1F *hphix = new TH1F("hphix", "phi with hits in TOFW", 500, -70., 70.);
	prim(hphi, "phi [degree]"); prim(hphix, "phi [degree]");
	TH1F *htheta = new TH1F("htheta", "theta", 500, -10., 70.);
	TH1F *hthetax = new TH1F("hthetax", "theta with hits in TOFW", 500, -10., 70.);
	prim(htheta, "theta [degree]"); prim(hthetax, "theta [degree]");
	TH2F *h2ang = new TH2F("h2ang", "theta vs phi", 500, -70., 70., 500, -10., 70.);
	TH2F *h2angx = new TH2F("h2angx", "theta vs phi with hits in TOFW",
		500, -70., 70., 500, -10., 70.);
	prim2(h2ang, "phi [degree]", "theta [degree]");
	prim2(h2angx, "phi [degree]", "theta [degree]");
	v.push_back(hphi); v.push_back(htheta); v.push_back(h2ang);
	v.push_back(hphix); v.push_back(hthetax); v.push_back(h2angx);
	eg4->Project("hphi", "phi");
	eg4->Project("htheta", "theta");
	eg4->Project("h2ang", "theta:phi");
	// The TOFW has hits
	eg4->Project("hphix", "phi", "nhTOFW");
	eg4->Project("hthetax", "theta", "nhTOFW");
	eg4->Project("h2angx", "theta:phi", "nhTOFW");

	TCanvas *c = new TCanvas("c", "c", 2400, 1600);
	c->Divide(3,2);
	for(int i = 0; i < 6; i++){ c->cd(i+1); v[i]->Draw(); }
	const double n = hphi->GetEntries(), na = hphix->GetEntries();
	cout << "n: " << n << ", n(accepted): " << na;
	cout << ", eff: \033[1m" << 100. * na / n << "%\033[0m" << endl;
	cout << "eff*0.25: \033[1m" << 25. * na / n << "%\033[0m" << endl;
	strtok(rf, ".");
	c->Print(Form("/home/asia/Pictures/Screenshots/%s.png", rf));
	c->Write("", TObject::kOverwrite);
} // end main function
